const { Transform } = require('stream');
const utils = require('../../utils');

module.exports = function () {
  const stream = new Transform({ objectMode: true });
  stream._transform = async function (chunk, encoding, callback) {
    utils.debug('objectTransform [chunk]:', chunk);
    stream.push(JSON.parse(JSON.stringify(chunk)));
    callback();
  };
  stream.on('finish', function () {
    utils.debug('objectTransform [finish]');
  });
  return stream;
};